import sqlite3

conn = sqlite3.connect("test.db") # 打开或创建一个数据库文件

print("Opened database successfully")

c = conn.cursor()

# create a new table
# sql = '''
# 	create table company
# 		(id int primary key not null,
# 		name text not null,
# 		age int not null,
# 		address char(50),
# 		salary real);
# '''

# create a record
# sql = '''
# 	insert into company(id,name,age,address,salary)
# 	values(1,'zhangsan',32,'chengdu',8000);
# '''

# select a record
sql = "select id, name, address, salary from company"
cursor = c.execute(sql)

for row in cursor:
	print("id = ", row[0])

c.execute(sql)
conn.commit()
conn.close()